package com.yudongyang.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yudongyang.dao.PatientMapper;
import com.yudongyang.domain.Disease;
import com.yudongyang.domain.Patient;
import com.yudongyang.service.PatientService;
import com.yudongyang.util.Cunhuo;
import com.yudongyang.util.getAge;
@Service
public class PatientServiceImpl implements PatientService {

	@Resource
	private PatientMapper patientMapper;

	//列表
	@Override
	public PageInfo<Patient> list(Patient p, Integer pageNum, Integer pageSize) {
		PageHelper.startPage(pageNum, pageSize);
		List<Patient> list = patientMapper.selects(p);
		for (Patient patient : list) {
			patient.setAge(getAge.getAge(patient.getBirthday()));
			patient.setCunhuo(Cunhuo.cunhuo(patient.getDiagnosed()));
		}
		return new PageInfo<Patient>(list);
	}
	//获得所有的疾病
	@Override
	public List<Disease> getDisease() {
		// TODO Auto-generated method stub
		return patientMapper.getDisease();
	}

	//添加
	@Override
	public int add(Patient p) {
		// TODO Auto-generated method stub
		return patientMapper.add(p);
	}

	//过得一个
	@Override
	public Patient getOne(String id) {
		// TODO Auto-generated method stub
		return patientMapper.getOne(id);
	}

	//修改
	@Override
	public int update(Patient p) {
		// TODO Auto-generated method stub
		return patientMapper.update(p);
	}
}
